package com.lnsoft.cac.server.handle.webservice.MsgHandle;

import lombok.extern.slf4j.Slf4j;
import org.jdom2.Document;
import org.jdom2.Element;
import org.jdom2.output.Format;
import org.jdom2.output.XMLOutputter;

@Slf4j
public class UploadCtrlResult {
    private Element rootNode;
    private Document doc;
    private Element resultNode;

    public UploadCtrlResult() {
        this.rootNode = new Element("request");
        this.doc = new Document(this.rootNode);
        this.resultNode = new Element("result");
        this.rootNode.addContent(this.resultNode);
    }

    public void setResultNodeAttr(String cmdId, String code) {
        cmdId.trim();
        code.trim();
        this.resultNode.setAttribute("commandid", cmdId);
        this.resultNode.setAttribute("code", code);
    }

    public String getMsg() {
        XMLOutputter XMLOut = new XMLOutputter(Format.getPrettyFormat());
        return XMLOut.outputString(this.doc);
    }
}
